package com.zzgele.qmzb.api.web;

import com.alibaba.boot.dubbo.annotation.DubboConsumer;
import com.zzgele.qmzb.api.core.Result;
import com.zzgele.qmzb.api.core.ResultGenerator;
import com.zzgele.qmzb.api.model.Feedback;
import com.zzgele.qmzb.api.service.FeedbackService;
import com.zzgele.qmzb.api.utils.DateUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
* Created by Martin on 2017/07/13.
*/
@RestController
@RequestMapping("/feedback")
public class FeedbackController {
    private final Logger logger = LoggerFactory.getLogger(FeedbackController.class);
    @DubboConsumer
    private FeedbackService feedbackService;

    @PostMapping("/create")
    public Result create(Long login_uid, Integer type_id, String content) {
        Feedback feedback = new Feedback();
        feedback.setContent(content);
        feedback.setCreateTime(DateUtil.getCurUnixTimeStampInt());
        feedback.setPicture("");
        feedback.setStatus(0);
        feedback.setTypeId(type_id);
        feedback.setUid(login_uid);
        feedback.setUpdateTime(0);
        feedbackService.save(feedback);

        return ResultGenerator.genSuccessResult("提交成功，感谢您的反馈");
    }
}
